<template>
  <div>
    <SelfAdaption slot="adaption-bar">
      <Form :model="RemindsearchForm" ref="formSearch" slot="adaption-bar" class="ivu-form-no-margin-bottom" inline>
        <Form-item prop="code" label="规则组名称：">
          <Input type="text" placeholder="请输入规则组名称" v-model="RemindsearchForm.ruleGroupName"></Input>
        </Form-item>
        <Form-item prop="reportName" label="领域：">
          <Select
            style="width: 100%"
            clearable
            placeholder="请选择领域"
            v-model="RemindsearchForm.reportName"
          >
            <Option v-for="item in reportNameList" :value="item.vsiValue" :key="item.vsiValue">{{ item.vsiValue }}</Option>
          </Select>
        </Form-item>
        <Form-item prop="locked" label="发送状态：">
          <Select
            style="width: 100%"
            clearable
            placeholder="请选择发送状态"
            v-model="RemindsearchForm.state"
          >
            <Option v-for="item in StatusList" :value="item.value" :key="item.value">{{ item.text }}</Option>
          </Select>
        </Form-item>
        <Form-item prop="triggerCondition" label="触发条件：">
          <Select
            style="width: 100%"
            clearable
            placeholder="请选择触发条件"
            v-model="RemindsearchForm.triggerCondition"
          >
            <Option v-for="item in triggerConditionList" :value="item.value" :key="item.value">{{ item.text }}</Option>
          </Select>
        </Form-item>
        <!--  查询 -->
        <Form-item prop="button" class="search-solt-btn">
          <RPButton optType="search" ref="search" @click="searchRemindValue" />
        </Form-item>
      </Form>
    </SelfAdaption>
    <InnerPageTable ref="RemindRecordTable" :config="pageTableConfig" v-if='showTable'>
      <div slot="table-bar"></div>
    </InnerPageTable>
  </div>
</template>

<script>
import { RemindRecordLists, columnListRemindRecord } from './columns.js'
import recordDetailModal from './recordDetailModal.vue'
import readApi from '../../../api/read.js'
import {
  SEND_STATE_LIST,
  TRIGGER_CONDITION_LIST
} from './const.js'
import coverApi from '@/api/cover.js'
import tableColumnSetting from '@/mixin/tableColumnSetting'
export default {
  name: 'RemindRecord',
  mixins: [tableColumnSetting],
  data() {
    return {
      pageTableConfig: {
        loadDataFn: this.getRemindRecordList,
        columns: RemindRecordLists.bind(this)(),
        autoFirst: false
      },
      RemindsearchForm: {
        id: '',
        ruleGroupName: '',
        reportName: '',
        //tableCode:'',
        state: '',
        triggerCondition: '',
      },
      StatusList: SEND_STATE_LIST,
      reportNameList: [
        // {text: '关键业务环节数字化覆盖度', value: '关键业务环节数字化覆盖度'},
        {text: '数字化转型专项实施方案任务表', value: '数字化转型专项实施方案任务表'}
      ],
      triggerConditionList: TRIGGER_CONDITION_LIST,
      menuNo: 'remindRecord',
      columnList: columnListRemindRecord,
    }
  },
  created() {
    // TODO：这里需要换成新接口
    coverApi.getCodeManage(
        {
          commonPageDTO: { currentPage: 1, pageSize: 10 },
          condition: { tenantCode: 'IT_SHARE_DEVELOP', vsCode: 'REPORT_FORMS' },
          pageNum: 1,
          pageSize: 10,
          sortDTO: { fieldName: '', orderBy: '' },
          tenantCode: 'IT_SHARE_DEVELOP',
          vsCode: 'REPORT_FORMS'
        }
      ).then(res => {
        this.reportNameList = res.data.records
      })
  },
  methods: {
    goDetail(row) {
      new this.$sidelipPage(
        recordDetailModal,
        {
          props: {
            title: '详情',
            data: row
          }
        },
        data => {
          data && this.searchInfo()
        }
      )
    },
    searchRemindValue() {
      this.$refs['RemindRecordTable'].load(this.RemindsearchForm)
    },
    getRemindRecordList: tableObj => {
      let { responseProcess, param } = tableObj
      let { pageNum, pageSize, ruleGroupName, reportName, state, triggerCondition } = param
      readApi.getReadTableList({
        sortDTO: {
          fieldName: "create_time",
          orderBy: "DESC"
        },
        condition: {
          ruleGroupName,
          reportName,
          state,
          triggerCondition,
        },
        pageNum,
        pageSize,
      }).then(res => {
       let { pageNum, pageSize, records, pages, total } = res.data.data
        responseProcess({
          pageNum,
          size: pageSize,
          pages,
          records: records || [],
          total,
        });
      })
    },
    init() {
      this.searchRemindValue()
    }
  },
}
</script>

<style>
</style>
